﻿using System.Data;

namespace DAL
{
    public static class DalGroupUser
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetGroupUser(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_Group_User");
        }
        public static DataTable GetGroupUserEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Group_Id", id);
            return Cls.GetData("sp_Group_User_GetEdit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtGroupUser obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Group_User_Code", obj.GroupUserCode);
            Cls.AddParameter("@Group_Name", obj.GroupName);
            Cls.AddParameter("@Descripttion", obj.Descripttion);
            return Cls.ExecuteNonQuery("sp_Group_User_Insert");
        }
        public static bool Update(EtGroupUser obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Group_Id", obj.GroupId);
            Cls.AddParameter("@Group_User_Code", obj.GroupUserCode);
            Cls.AddParameter("@Group_Name", obj.GroupName);
            Cls.AddParameter("@Descripttion", obj.Descripttion);
            return Cls.ExecuteNonQuery("sp_Group_User_Update");
        }
        public static bool Delete(EtGroupUser obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Group_Id", obj.GroupId);
            obj.msg = Cls.ExecuteNonQueryOutput("sp_Group_User_Del", "@MSG");
            return true;
        }
        #endregion
    }

    public class EtGroupUser
    {
        public int GroupId { get; set; }
        public string GroupName { get; set; }
        public string Descripttion { get; set; }
        public string GroupUserCode { get; set; }
        public int msg { get; set; }
    }
}
